function getUrl(name) {
    var res = 1;
    $.ajax({  
        type:'get',      
        url:'js/config.json',
        async : false, 
        dataType: "json",  
        success:function(data){
            res = data.url[name];
            //console.log(res);
        }  
    });
    return res;
}
function drawCircle(obj,max,val){
    var num = (val/max)*100 * 3.6;
    if (num<=180) {
        obj.find('.circle_right').css('transform', "rotate(" + num + "deg)");
    } else {
        obj.find('.circle_right').css('transform', "rotate(180deg)");
        obj.find('.circle_left').css('transform', "rotate(" + (num - 180) + "deg)");
    };
}
function changeColor(obj,val){
    if (val == 1) {
        obj.css('background','#00cf41');
    }else if (val == 0) {
        obj.css('background','#f00');
    }else{
        obj.css('background','#b9b9b9');
    }
}
function reset(){
    $('.u-box').find('p').html("");
    $('.u-box').removeClass('printed');
    $('.u-box').removeClass('break');
    $('.u-box').removeClass('empty');
    $('.u-box').removeClass('backprinted');
    $('.u-box').removeClass('prewprinted');
    $('.u-box').removeClass('printed1');
    $('.u-box').removeClass('printed3');
}
function count(obj,index){
    for (var i = 0; i < obj.length; i++) {
       (function(i){
            $('.u-box'+obj[i].stack_index).find('p').html(obj[i].silicon_id);    
            //console.log(obj[i].stack_index);
            var tmp = i+1;
            if (obj[i].isPause == 1){
                $('.u-box'+obj[i].stack_index).addClass('stop');
            }
            if (obj[i].silicon_id) {
                if (obj[i].silicon_status == 1) {
                    if (index == 0) {
                        $('.u-box'+obj[i].stack_index).addClass('prewprinted');
                    }else if (index == 1) {
                        $('.u-box'+obj[i].stack_index).addClass('backprinted');
                    }else if(index == 2){
                        $('.u-box'+obj[i].stack_index).addClass('backprinted');
                    }else if(index == 3){
                        $('.u-box'+obj[i].stack_index).addClass('printed1');
                    }else if(index == 4){
                        $('.u-box'+obj[i].stack_index).addClass('printed');
                    }else{
                        $('.u-box'+obj[i].stack_index).addClass('printed3');
                    }
                }else if(obj[i].silicon_status == 0){
                    if (index == 0) {
                        $('.u-box'+obj[i].stack_index).addClass('prewprinted');
                    }else if (index == 1) {
                        $('.u-box'+obj[i].stack_index).addClass('backprinted');
                    }else if(index == 2){
                        $('.u-box'+obj[i].stack_index).addClass('backprinted');
                    }else if(index == 3){
                        $('.u-box'+obj[i].stack_index).addClass('printed1');
                    }else if(index == 4){
                        $('.u-box'+obj[i].stack_index).addClass('printed');
                    }else{
                        $('.u-box'+obj[i].stack_index).addClass('printed3');
                    }
                }else{
                    if (index == 0) {
                        $('.u-box'+obj[i].stack_index).addClass('prewprinted');
                    }else if (index == 1) {
                        $('.u-box'+obj[i].stack_index).addClass('backprinted');
                    }else if(index == 2){
                        $('.u-box'+obj[i].stack_index).addClass('backprinted');
                    }else if(index == 3){
                        $('.u-box'+obj[i].stack_index).addClass('printed1');
                    }else if(index == 4){
                        $('.u-box'+obj[i].stack_index).addClass('printed');
                    }else{
                        $('.u-box'+obj[i].stack_index).addClass('printed3');
                    }
                }
            }
            
       })(i); 
    }
}